define([
	'yf',
	'jquery',
	"text!./template/carListTpl.html",
	"text!./template/translateMenu.html",
	"yfUtil"],
	function(yf,$,carListTpl,translateMenu,yfUtil){
	var me;
	var carList = {
		initialize:function(){
			me = this;
            var navigateArg = me.getNavigateArg();
            var navigateArg = {code:"001"}
            me.createTranslate();
            
		},
		
		bindEvents:{
			'click .translateLi':'createList',
			'click .carListLi':"goProduct"
		},
		
		createTranslate:function(){
			$.ajax({
				type:"get",
				url:"./data/translateMenu.json",
				async:true,
				success:function(data){
					data = yfUtil.stringTranObj(data).data;
					yfUtil.createTemplate(translateMenu,data,$('#translateDiv'));
					me.$el.find('#translateDiv div')[0].click();
				}
			});
		},
		
		//直接生成列表的方法
        createList:function(e){
        	var code = $(e.target).attr("data-id");
        	var url = "./data/"+code+".json";
        	$.ajax({
        		type:"get",
        		url:url,
        		async:true,
        		success:function(data){
        			if(typeof data=="string"){
        				data = JSON.parse(data);
        			}
        			console.log(data);
        			$('.carListDiv').html(_.template($(carListTpl).html())({result:data.data}));
        		}
        	});
        },
        
        goProduct:function(){
        	yf.openWebPage('../product/index.html#main');
        }
	}
	return carList;
});